package utilities 
{
	import enemy.Exorcist;
	import org.flixel.FlxObject;
	/**
	 * ...
	 * 
	 * Naive implementation of an event. Just for proof of concept. The other way we can do events is to just add callbacks into
	 * into objects specfically so they have a an array of callbacks to call when something occurs.
	 * 
	 * @author Andrew Lau
	 */
	public class Event 
	{
		
		private var func:Function;
		private var args:Array;
		
		private var or:Array;
		private var and:Array;
		
		private var object:FlxObject;
		private var _executed:Boolean;
		
		public function Event(func:Function, ... args) 
		{
			this.func = func;
			this.args = args;
			this._executed = false;
		}
		
		public function afterKilled(object:FlxObject):Modifier
		{
			this.object = object;
			
			return new Modifier();
		}
		
		public function get ready():Boolean
		{
			return this.object == null || (!object.exists && !object.alive);
		}
		
		public function execute():void
		{
			this.func.apply(null, args[0]);
			_executed = true;
		}
		
		public function get executed():Boolean
		{
			return _executed;
		}
		
	}

}